package com.munhrasoft.elearning.business.entities;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

@Entity
@NamedQueries(value = {
    @NamedQuery(name = "findAllStudents", query = "SELECT s FROM Students s"),
    @NamedQuery(name = "findStudentsByName", query = "SELECT s FROM Students s WHERE lower(s.name) "
            + "LIKE :name") })
@SequenceGenerator(name = "studentsSeq", initialValue = 1, allocationSize = 1)
public class Students {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "studentsSeq")
    private Long          id;
    private String        name;
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<Courses> courses;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Courses> getCourses() {
        return courses;
    }

    public void setCourses(List<Courses> courses) {
        this.courses = courses;
    }

}
